B16 - Frog 1
https://atcoder.jp/contests/tessoku-book/tasks/dp_a
提出
code: python
n = int(input())
h = list(map(int, input().split()))
# 0 1 2 3
# 10 30 40 20
# dp
i
:= i にいるときの最小
dp =
0
* n
dp
0
= 0
dp
1
= abs(h
0
- h
1
)
for i in range(2, n):
dp
i
= min(dp
i-2
+ abs(h
i
- h
i-2
), dp
i-1
+ abs(h
i
- h
i-1
))
print(dp
-1
)